package com.qvtu.poetry.entry;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import lombok.Data;

/**
 * 草稿箱关联表
 * @TableName t_draft
 */
@TableName(value ="t_draft")
@Data
public class Draft {
    /**
     * 草稿唯一标识
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 草稿所属用户ID
     */
    private Long userId;

    /**
     * 关联诗歌ID
     */
    private Long poemId;

    /**
     * 最后编辑时间
     */
    private LocalDateTime lastEditTime;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Draft other = (Draft) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getPoemId() == null ? other.getPoemId() == null : this.getPoemId().equals(other.getPoemId()))
            && (this.getLastEditTime() == null ? other.getLastEditTime() == null : this.getLastEditTime().equals(other.getLastEditTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getPoemId() == null) ? 0 : getPoemId().hashCode());
        result = prime * result + ((getLastEditTime() == null) ? 0 : getLastEditTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", userId=").append(userId);
        sb.append(", poemId=").append(poemId);
        sb.append(", lastEditTime=").append(lastEditTime);
        sb.append("]");
        return sb.toString();
    }
}